#include <iostream>
#include "majestic.h"
using namespace std;
int main()
{
    Majestic::Screen a(800,600,2,2);
    Majestic::Object o1(0,0,"media/bg.bmp");
    Majestic::Object o2(490,80,"media/drzewo.bmp");
    //Majestic::Object o3(0,0,"media/bg.bmp");
    Majestic::Slate s1;
    Majestic::Slate s2;
    s1.addobject(o1);
    s2.addobject(o2);
    a.addslate(0,0,s1);
    a.addslate(1,1,s2);
    a.setcamera(0,0);
    a.movecamera(10,20);
    Majestic::Sound s;
    Majestic::Player p(100,100,"media/1.png","media/2.png","media/3.png","media/4.png","media/5.png","media/6.png","media/7.png","media/8.png");
    //cout << p.getx() << endl;
    a.addplayer(p);
    //a.drawplayer();
    int tmp;
    //s.queue("media/ost2.ogg");
    //int c = s.queue("media/ost2.ogg");
    //s.setvolume(100);
    //s.play(c+1);
    //cout << c;

    int i;
    while(a.isOpened())
    {
    cout << "Code:"<<tmp<<endl;
    tmp=a.getkey();
    if (a.getstate()==1)
    {
        p.move(0,-5);
        a.movecamera(0,-5);
        p.changepos(0);
    }
    if (a.getstate()==2)
    {
        p.move(0,5);
        a.movecamera(0,5);
        p.changepos(0);
    }
    if (a.getstate()==3)
    {
        p.move(-5,0);
        a.movecamera(-5,0);
        p.changepos(2);
    }if (a.getstate()==4)
    {
        p.move(5,0);
        a.movecamera(5,0);
        p.changepos(1);
    }

    if (a.getstate()==103)
    {
        p.move(-5,-5);
        a.movecamera(-5,-5);
        p.changepos(7);
    }
    if (a.getstate()==104)
    {
        p.move(5,-5);
        a.movecamera(5,-5);
        p.changepos(6);
    }
    if (a.getstate()==203)
    {
        p.move(-5,5);
        a.movecamera(-5,5);
        p.changepos(4);
    }if (a.getstate()==204)
    {
        p.move(5,5);
        a.movecamera(5,5);
        p.changepos(5);
    }
    if (tmp==0)
    {
        a.quit() ;
        break;
    }
        a.setbg(0,0,0);
    a.drawobjects();
    a.drawplayer();
    //a.addtxt("dupa","media/font1.ttf",50,50,50,50,50,50);

    a.refresh();
    }


	return 0;

}

